package datasource;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class SqliteConnection {
	
	
	
	public static void main(String[] args) {
		Connection c = null;
		Statement stmt = null;
		
	try {
		
		  Class.forName("org.sqlite.JDBC");
	      c = DriverManager.getConnection("jdbc:sqlite:db/test.db");
	      stmt = c.createStatement();
	      ResultSet rs = stmt.executeQuery("select * from company");
	      while(rs.next()){
	    	  int id = rs.getInt("id");
	    	  String name = rs.getString("name");
	    	  int age = rs.getInt("age");
	    	  String address = rs.getString("address");
	    	  
	    	  float salary = rs.getFloat("salary");
	    	  System.out.println(rs.getString(5) + "=======");
	    	  System.out.println( "ID = " + id );
	          System.out.println( "NAME = " + name );
	          System.out.println( "AGE = " + age );
	          System.out.println( "ADDRESS = " + address );
	          System.out.println( "SALARY = " + salary );
	          System.out.println();
	      }
	      rs.close();
	      stmt.close();
	      c.close();
	      
	      } catch (Exception e) {
			System.err.println(e.getClass().getName() +": " + e.getMessage());
			System.exit(0);
		}
	}

}
